{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "2795f3de-d19a-4b45-bf53-1291ebcbb4af",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Pyehcarts共有有四种地理图表，最基础的也是我们等下要说明的\n",
    "# Map：地图\n",
    "# Geo：地理坐标系\n",
    "# BMap：百度地图\n",
    "# Map3D：三维地图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "63da16af-7514-4752-899e-6a0450364994",
   "metadata": {},
   "outputs": [],
   "source": [
    "from pyecharts.charts import Map\n",
    "from pyecharts import options as opts\n",
    "\n",
    "# Notebook显示图例\n",
    "from pyecharts.globals import CurrentConfig, NotebookType\n",
    "CurrentConfig.NOTEBOOK_TYPE = NotebookType.NTERACT"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "1d1a4019-81e2-4f28-a9b9-c835424ca8d6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<pyecharts.charts.basic_charts.map.Map at 0x7f7fd10468b0>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = [('北京', 52912), \n",
    "        ('天津', 38975), \n",
    "        ('河北', 15893), \n",
    "        ('山西', 18132), \n",
    "        ('内蒙古', 23909), \n",
    "        ('辽宁', 24866), \n",
    "        ('吉林', 15083), \n",
    "        ('黑龙江', 18859), \n",
    "        ('上海', 53617), \n",
    "        ('江苏', 39796), \n",
    "        ('浙江', 33851), \n",
    "        ('安徽', 17141), \n",
    "        ('福建', 25969), \n",
    "        ('江西', 17290), \n",
    "        ('山东', 28353), \n",
    "        ('河南', 17842), \n",
    "        ('湖北', 21642), \n",
    "        ('湖南', 19418), \n",
    "        ('广东', 30762), \n",
    "        ('广西', 16064), \n",
    "        ('海南', 20939), \n",
    "        ('重庆', 22927), \n",
    "        ('四川', 17920), \n",
    "        ('贵州', 16349), \n",
    "        ('云南', 15831), \n",
    "        ('西藏', 10990), \n",
    "        ('陕西', 18485), \n",
    "        ('甘肃', 14203), \n",
    "        ('青海', 18020), \n",
    "        ('宁夏', 21058), \n",
    "        ('新疆', 16736),\n",
    "        ('台湾', 18322)]\n",
    "map_ = Map()\n",
    "map_.add(\n",
    "    series_name = '居民消费水平',\n",
    "    data_pair = data,\n",
    "    maptype = 'china',\n",
    "    zoom = 1\n",
    ")\n",
    "map_.set_global_opts(\n",
    "    title_opts = opts.TitleOpts(\n",
    "        title = '2017年居民消费水平（元）',\n",
    "        subtitle = '数据来源：国家统计局',\n",
    "        pos_right = 'center',\n",
    "        pos_top = '5%'\n",
    "    ),\n",
    "    visualmap_opts = opts.VisualMapOpts(\n",
    "        max_ = 53617,\n",
    "        min_ = 10990,\n",
    "        range_color = ['#1E9600', '#FFF200', '#FF0000']\n",
    "    )\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "1a2882f5-f18d-44b7-aa87-9bf168cd2910",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<!DOCTYPE html>\n",
       "<html>\n",
       "<head>\n",
       "    <meta charset=\"UTF-8\">\n",
       "    <title>Awesome-pyecharts</title>\n",
       "            <script type=\"text/javascript\" src=\"https://assets.pyecharts.org/assets/echarts.min.js\"></script>\n",
       "        <script type=\"text/javascript\" src=\"https://assets.pyecharts.org/assets/maps/china.js\"></script>\n",
       "\n",
       "</head>\n",
       "<body>\n",
       "    <div id=\"2ac932050f5e4c37befb8ec0ce47ed7b\" class=\"chart-container\" style=\"width:900px; height:500px;\"></div>\n",
       "    <script>\n",
       "        var chart_2ac932050f5e4c37befb8ec0ce47ed7b = echarts.init(\n",
       "            document.getElementById('2ac932050f5e4c37befb8ec0ce47ed7b'), 'white', {renderer: 'canvas'});\n",
       "        var option_2ac932050f5e4c37befb8ec0ce47ed7b = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"map\",\n",
       "            \"name\": \"\\u5c45\\u6c11\\u6d88\\u8d39\\u6c34\\u5e73\",\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"mapType\": \"china\",\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u5317\\u4eac\",\n",
       "                    \"value\": 52912\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5929\\u6d25\",\n",
       "                    \"value\": 38975\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6cb3\\u5317\",\n",
       "                    \"value\": 15893\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5c71\\u897f\",\n",
       "                    \"value\": 18132\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5185\\u8499\\u53e4\",\n",
       "                    \"value\": 23909\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8fbd\\u5b81\",\n",
       "                    \"value\": 24866\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5409\\u6797\",\n",
       "                    \"value\": 15083\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9ed1\\u9f99\\u6c5f\",\n",
       "                    \"value\": 18859\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4e0a\\u6d77\",\n",
       "                    \"value\": 53617\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6c5f\\u82cf\",\n",
       "                    \"value\": 39796\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6d59\\u6c5f\",\n",
       "                    \"value\": 33851\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5b89\\u5fbd\",\n",
       "                    \"value\": 17141\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u798f\\u5efa\",\n",
       "                    \"value\": 25969\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6c5f\\u897f\",\n",
       "                    \"value\": 17290\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5c71\\u4e1c\",\n",
       "                    \"value\": 28353\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6cb3\\u5357\",\n",
       "                    \"value\": 17842\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e56\\u5317\",\n",
       "                    \"value\": 21642\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e56\\u5357\",\n",
       "                    \"value\": 19418\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5e7f\\u4e1c\",\n",
       "                    \"value\": 30762\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5e7f\\u897f\",\n",
       "                    \"value\": 16064\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6d77\\u5357\",\n",
       "                    \"value\": 20939\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u91cd\\u5e86\",\n",
       "                    \"value\": 22927\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u56db\\u5ddd\",\n",
       "                    \"value\": 17920\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8d35\\u5dde\",\n",
       "                    \"value\": 16349\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4e91\\u5357\",\n",
       "                    \"value\": 15831\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u897f\\u85cf\",\n",
       "                    \"value\": 10990\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9655\\u897f\",\n",
       "                    \"value\": 18485\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u7518\\u8083\",\n",
       "                    \"value\": 14203\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9752\\u6d77\",\n",
       "                    \"value\": 18020\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5b81\\u590f\",\n",
       "                    \"value\": 21058\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u65b0\\u7586\",\n",
       "                    \"value\": 16736\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u53f0\\u6e7e\",\n",
       "                    \"value\": 18322\n",
       "                }\n",
       "            ],\n",
       "            \"roam\": true,\n",
       "            \"aspectScale\": 0.75,\n",
       "            \"nameProperty\": \"name\",\n",
       "            \"selectedMode\": false,\n",
       "            \"zoom\": 1,\n",
       "            \"mapValueCalculation\": \"sum\",\n",
       "            \"showLegendSymbol\": true,\n",
       "            \"emphasis\": {}\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u5c45\\u6c11\\u6d88\\u8d39\\u6c34\\u5e73\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u5c45\\u6c11\\u6d88\\u8d39\\u6c34\\u5e73\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"2017\\u5e74\\u5c45\\u6c11\\u6d88\\u8d39\\u6c34\\u5e73\\uff08\\u5143\\uff09\",\n",
       "            \"subtext\": \"\\u6570\\u636e\\u6765\\u6e90\\uff1a\\u56fd\\u5bb6\\u7edf\\u8ba1\\u5c40\",\n",
       "            \"right\": \"center\",\n",
       "            \"top\": \"5%\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"visualMap\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"continuous\",\n",
       "        \"min\": 10990,\n",
       "        \"max\": 53617,\n",
       "        \"inRange\": {\n",
       "            \"color\": [\n",
       "                \"#1E9600\",\n",
       "                \"#FFF200\",\n",
       "                \"#FF0000\"\n",
       "            ]\n",
       "        },\n",
       "        \"calculable\": true,\n",
       "        \"inverse\": false,\n",
       "        \"splitNumber\": 5,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"showLabel\": true,\n",
       "        \"itemWidth\": 20,\n",
       "        \"itemHeight\": 140,\n",
       "        \"borderWidth\": 0\n",
       "    }\n",
       "};\n",
       "        chart_2ac932050f5e4c37befb8ec0ce47ed7b.setOption(option_2ac932050f5e4c37befb8ec0ce47ed7b);\n",
       "    </script>\n",
       "</body>\n",
       "</html>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x7f7fc093cb20>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "map_.render_notebook()\n",
    "# map_.render('map.html')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d99f820b-183a-41a6-83a8-35fc98fa3ab4",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8786f491-2b94-4f62-90b4-e0260864ac82",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
